<!DOCTYPE html>
<html>
<head>
    <link rel="shortcut icon" href="/web/favicon.ico">
    <link href="/web/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/web/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="/web/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=20210202" rel="stylesheet"/>
    <link href="/web/css/animate.min.css" rel="stylesheet"/>
    <link href="/web/css/style.css?v=20200903" rel="stylesheet"/>
    <link href="/web/andy/css/ry-ui.css?v=4.6.1" rel="stylesheet"/>
    <a id="scroll-up" href="javascript:void(0);" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
    <script src="/web/js/jquery.min.js"></script>
    <script src="/web/js/bootstrap.min.js"></script>
    <!-- bootstrap-table 表格插件 -->
    <script src="/web/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/web/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20210202"></script>
    <script src="/web/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js"></script>
    <!-- jquery-validate 表单验证插件 -->
    <script src="/web/ajax/libs/validate/jquery.validate.min.js"></script>
    <script src="/web/ajax/libs/validate/messages_zh.min.js"></script>
    <script src="/web/ajax/libs/validate/jquery.validate.extend.js"></script>
    <!-- jquery-validate 表单树插件 -->
    <script src="/web/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
    <!-- 遮罩层 -->
    <script src="/web/ajax/libs/blockUI/jquery.blockUI.js"></script>
    <script src="/web/ajax/libs/iCheck/icheck.min.js"></script>
    <script src="/web/ajax/libs/layer/layer.min.js"></script>
    <script src="/web/ajax/libs/layui/layui.js"></script>
    <script src="/web/andy/js/common.js?v=4.6.1"></script>
    <script src="/web/andy/js/andy-ui.js?v=4.6.1"></script>
    <script src="/webjars/vue/2.6.14/vue.min.js"></script>
    <link href="/web/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css" rel="stylesheet"/>
    <script src="/web/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
    <style type="text/css">.user-info-head{position:relative;display:inline-block;}.user-info-head:hover:after{content:'\f030';position:absolute;left:0;right:0;top:0;bottom:0;color:#eee;background:rgba(0,0,0,0.5);font-family:FontAwesome;font-size:24px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;cursor:pointer;line-height:110px;border-radius:50%;}</style>
</head>

<body class="gray-bg" style="font: 14px Helvetica Neue, Helvetica, PingFang SC, 微软雅黑, Tahoma, Arial, sans-serif !important;">
<div id="container">
    <!--修改密码-->
    <div class="tab-pane" id="modify_password">
        <form class="form-horizontal" id="form-user-resetPwd">
            <div class="form-group">
                <label class="col-sm-2 control-label">旧密码：</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" name="oldPassword"  id="oldPassword" placeholder="请输入旧密码">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">新密码：</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="newPassword" name="newPassword" v-model="user.password">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">确认密码：</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" name="confirmPassword" placeholder="请确认密码">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" class="btn btn-sm btn-primary" onclick="submitChangPassword()"><i class="fa fa-check"></i>保 存</button>&nbsp;
                    <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
                </div>
            </div>
        </form>
    </div>
</div>
    <script>
        var ctx='';
        var vm = new Vue({
            el:'#container',
            data:{
                entity:{
                    sex:'0'
                },
                user:{
                    password:'',
                }
            },
            mounted(){
                init();
            }
        });
        function init() {
            $.operate.getNoAlert('/system/user/userInfo',function(ret){
                vm.entity = ret.data;
            });
        }


		

	    /*用户管理-修改密码*/

		
		function submitChangPassword () {
			var chrtype = '';
			var password = $("#newPassword").val();
			var a = $("#form-user-resetPwd").valid();
	        if ($("#form-user-resetPwd").valid()) {
	            let user={userId:vm.entity.userId,password:vm.user.password,loginName:vm.entity.loginName};
                $.operate.post("/system/user/save",JSON.stringify(user));
	        }
	    }
	</script>
<script>
    $(function(){
        $("#form-user-resetPwd").validate({
            rules:{
                oldPassword:{
                    required:true,
                    remote: {
                        url: "/system/user/profile/checkPassword"
                    }
                },
                newPassword: {
                    required: true,
                    minlength: 6,
                    maxlength: 20
                },
                confirmPassword: {
                    required: true,
                    equalTo: "#newPassword"
                }
            },
            messages: {
                oldPassword: {
                    required: "请输入原密码",
                    remote: "原密码错误"
                },
                newPassword: {
                    required: "请输入新密码",
                    minlength: "密码不能小于6个字符",
                    maxlength: "密码不能大于20个字符"
                },
                confirmPassword: {
                    required: "请再次输入新密码",
                    equalTo: "两次密码输入不一致"
                }

            }
        });
    })
</script>
</body>
</html>
